#ifndef FILTER_CONTAINER_INCLUDED
#define FILTER_CONTAINER_INCLUDED

#include <iostream>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <map>
#include <list>
#include <queue>

#include "udp_sender.h"
#include "baseFilter.h"
#include "thread.h"
#include "server.h"


class FilterContainer : public ThreadProcess
{
	typedef std::list<BaseFilterPointer> BaseFilterList;

	class Agent {
	public:
		UDPSenderPointer udp_sender_pointer;
		BaseFilterList filter_list;
		time_t heartbeat_time;
	};
	typedef boost::shared_ptr<Agent> AgentPointer;
	typedef std::map<std::string, AgentPointer> BaseFilterListMap;

	bool process();

public:
	void updateSubscriptionContainer(std::string const& agentName);
	FilterContainer();
	UDPSenderPointer validate(Frame const& frame);
	void addFilter(BaseFilterPointer baseFilter, std::string const& agentName, socketTCP* socket);
	void erase(std::string const& agentName);
private:
	BaseFilterListMap m_filters;
	pthread_mutex_t m_lock;
};


#endif

